package com.firebird.app.fekpsl.adapter.sword.rank

import android.view.View
import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.firebird.app.fekpsl.R
import com.firebird.app.fekpsl.app.App.Companion.context
import com.firebird.app.fekpsl.bean.Fan
import com.firebird.app.fekpsl.utils.ImageLoader

/**
 * Created by firebird on 2018/4/22.
 */
class FanRankAdapter : BaseQuickAdapter<Fan, BaseViewHolder>(R.layout.sword_rank_item_fan_list) {
    override fun convert(helper: BaseViewHolder?, item: Fan?) {
        helper ?: return
        item ?: return

        val index=helper.layoutPosition

        val username = if (item.is_explicit==1) item.nice_name else item.real_name

        helper.setText(R.id.tv_user_name, username)
                .addOnClickListener(R.id.iv_avatar)
        val content = "粉丝数"+item.fan_num.toString()
        helper.setText(R.id.tv_content, content)
        if (item.avatar_text.isNotEmpty()) {
            helper.getView<ImageView>(R.id.iv_avatar)
                    .visibility = View.VISIBLE
            context?.let {
                ImageLoader.load(it, item.avatar_text, helper.getView(R.id.iv_avatar))
            }
        } else {
            helper.getView<ImageView>(R.id.iv_avatar)
                    .visibility = View.GONE
        }
        helper.setText(R.id.tv_ranking,(index+1).toString())
    }
}
